Welcome back. This lesson introduces the CSV format.
CSV is an acronym that stands for Comma Separated Values, CSV.
A file in CSV format is just a text file that follows certain conventions.
The CSV format says that values are going to be separated by
commas and it says that every line of the file will have the same structure.
So, for example, we've got two commas on every line,
One, two, one, two.
So, we've got room for three things on each line;
before the first comma,
between the first and second and after the second one.
Usually, you'll have the first line be special to give column names and then afterwards,
all the rest of the lines are similar to each other.
They each have values.
The first value on line two is a name,
the second value, 98 is a score, A+ plus is a grade.
The reason this format is nice is that by having this standard format,
you can have it read into lots of different programs.
So, I've chosen to name this file grades dot CSV and it's saved on this computer.
It's saved in this folder.
On a Mac, when you have a file name that ends in dot CSV,
unless you've configured your Mac some other way,
when you try to open it,
it defaults to thinking that you want to try to open it into an Excel spreadsheet.
So here, it's taken that and instead of showing it to me as a text file,
it's chopped it up and actually put
the first values into column A and the second values in the column B,
third values into column C. The same CSV format can be read not just by Excel,
but by all kinds of statistics programs stayed are SPSS and so on.
You can also open it in Google sheets.
So, here's my Google Drive folder where I have some of
my notes for these recordings and I've put that grades,
that same grades dot csv file here,
when I double-click on it,
it gives me a little preview of what it would look like and it gives me
an option to open it with Google sheets which is just another spreadsheet program.
It's doing its little conversion and now we see it again in columns.
So, the CSV format is kind of an interchange format.
It's just a text file but if you follow
the conventions and have the same number of commas on
each line then it's going to be possible for a file to be read by any of these programs.
At the end of this lesson,
you'll be able to read a text file whose contents are in
CSV format and pass the lines by using the dot split method.
You'll be able to write a text file whose contents are in CSV format
using either the dot format method with the string template or the dot join method.
See you at the end of the lesson when I'll
explain the difference between a cut and a comma.